package com.j256.ormlite.stmt;

import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.GenericRawResults;
import com.j256.ormlite.dao.ObjectCache;
import com.j256.ormlite.dao.RawRowMapper;
import com.j256.ormlite.dao.RawRowObjectMapper;
import com.j256.ormlite.db.DatabaseType;
import com.j256.ormlite.field.DataPersister;
import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.FieldType;
import com.j256.ormlite.field.SqlType;
import com.j256.ormlite.logger.Logger;
import com.j256.ormlite.logger.LoggerFactory;
import com.j256.ormlite.stmt.mapped.MappedCreate;
import com.j256.ormlite.stmt.mapped.MappedDelete;
import com.j256.ormlite.stmt.mapped.MappedDeleteCollection;
import com.j256.ormlite.stmt.mapped.MappedQueryForId;
import com.j256.ormlite.stmt.mapped.MappedRefresh;
import com.j256.ormlite.stmt.mapped.MappedUpdate;
import com.j256.ormlite.stmt.mapped.MappedUpdateId;
import com.j256.ormlite.support.CompiledStatement;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.support.DatabaseConnection;
import com.j256.ormlite.support.DatabaseResults;
import com.j256.ormlite.table.TableInfo;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class StatementExecutor<T, ID>
  implements GenericRowMapper<String[]>
{
  private static Logger logger = LoggerFactory.getLogger(StatementExecutor.class);
  private static final FieldType[] noFieldTypes = new FieldType[0];
  private String countStarQuery;
  private final Dao<T, ID> dao;
  private final DatabaseType databaseType;
  private FieldType[] ifExistsFieldTypes;
  private String ifExistsQuery;
  private MappedDelete<T, ID> mappedDelete;
  private MappedCreate<T, ID> mappedInsert;
  private MappedQueryForId<T, ID> mappedQueryForId;
  private MappedRefresh<T, ID> mappedRefresh;
  private MappedUpdate<T, ID> mappedUpdate;
  private MappedUpdateId<T, ID> mappedUpdateId;
  private PreparedQuery<T> preparedQueryForAll;
  private RawRowMapper<T> rawRowMapper;
  private final TableInfo<T, ID> tableInfo;

  public StatementExecutor(DatabaseType paramDatabaseType, TableInfo<T, ID> paramTableInfo, Dao<T, ID> paramDao)
  {
    this.databaseType = paramDatabaseType;
    this.tableInfo = paramTableInfo;
    this.dao = paramDao;
  }

  private void assignStatementArguments(CompiledStatement paramCompiledStatement, String[] paramArrayOfString)
    throws SQLException
  {
    for (int i = 0; i < paramArrayOfString.length; i++)
      paramCompiledStatement.setObject(i, paramArrayOfString[i], SqlType.STRING);
  }

  private void prepareQueryForAll()
    throws SQLException
  {
    if (this.preparedQueryForAll == null)
      this.preparedQueryForAll = new QueryBuilder(this.databaseType, this.tableInfo, this.dao).prepare();
  }

  public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> paramBaseDaoImpl, ConnectionSource paramConnectionSource, int paramInt, ObjectCache paramObjectCache)
    throws SQLException
  {
    prepareQueryForAll();
    return buildIterator(paramBaseDaoImpl, paramConnectionSource, this.preparedQueryForAll, paramObjectCache, paramInt);
  }

  public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> paramBaseDaoImpl, ConnectionSource paramConnectionSource, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache, int paramInt)
    throws SQLException
  {
    DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
    CompiledStatement localCompiledStatement = null;
    try
    {
      localCompiledStatement = paramPreparedStmt.compile(localDatabaseConnection, StatementBuilder.StatementType.SELECT, paramInt);
      SelectIterator localSelectIterator = new SelectIterator(this.tableInfo.getDataClass(), paramBaseDaoImpl, paramPreparedStmt, paramConnectionSource, localDatabaseConnection, localCompiledStatement, paramPreparedStmt.getStatement(), paramObjectCache);
      if (0 != 0)
        null.close();
      if (0 != 0)
        paramConnectionSource.releaseConnection(null);
      return localSelectIterator;
    }
    finally
    {
      if (localCompiledStatement != null)
        localCompiledStatement.close();
      if (localDatabaseConnection != null)
        paramConnectionSource.releaseConnection(localDatabaseConnection);
    }
  }

  // ERROR //
  public <CT> CT callBatchTasks(DatabaseConnection paramDatabaseConnection, boolean paramBoolean, java.util.concurrent.Callable<CT> paramCallable)
    throws SQLException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 67	com/j256/ormlite/stmt/StatementExecutor:databaseType	Lcom/j256/ormlite/db/DatabaseType;
    //   4: invokeinterface 155 1 0
    //   9: ifeq +18 -> 27
    //   12: aload_1
    //   13: iload_2
    //   14: aload_0
    //   15: getfield 67	com/j256/ormlite/stmt/StatementExecutor:databaseType	Lcom/j256/ormlite/db/DatabaseType;
    //   18: aload_3
    //   19: invokestatic 161	com/j256/ormlite/misc/TransactionManager:callInTransaction	(Lcom/j256/ormlite/support/DatabaseConnection;ZLcom/j256/ormlite/db/DatabaseType;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
    //   22: astore 10
    //   24: aload 10
    //   26: areturn
    //   27: iconst_0
    //   28: istore 4
    //   30: aload_1
    //   31: invokeinterface 166 1 0
    //   36: istore 6
    //   38: iconst_0
    //   39: istore 4
    //   41: iload 6
    //   43: ifeq +38 -> 81
    //   46: aload_1
    //   47: invokeinterface 169 1 0
    //   52: istore 4
    //   54: iload 4
    //   56: ifeq +25 -> 81
    //   59: aload_1
    //   60: iconst_0
    //   61: invokeinterface 173 2 0
    //   66: getstatic 57	com/j256/ormlite/stmt/StatementExecutor:logger	Lcom/j256/ormlite/logger/Logger;
    //   69: ldc 175
    //   71: aload_0
    //   72: getfield 69	com/j256/ormlite/stmt/StatementExecutor:tableInfo	Lcom/j256/ormlite/table/TableInfo;
    //   75: invokevirtual 178	com/j256/ormlite/table/TableInfo:getTableName	()Ljava/lang/String;
    //   78: invokevirtual 184	com/j256/ormlite/logger/Logger:debug	(Ljava/lang/String;Ljava/lang/Object;)V
    //   81: aload_3
    //   82: invokeinterface 190 1 0
    //   87: astore 9
    //   89: aload 9
    //   91: astore 10
    //   93: iload 4
    //   95: ifeq -71 -> 24
    //   98: aload_1
    //   99: iconst_1
    //   100: invokeinterface 173 2 0
    //   105: getstatic 57	com/j256/ormlite/stmt/StatementExecutor:logger	Lcom/j256/ormlite/logger/Logger;
    //   108: ldc 192
    //   110: aload_0
    //   111: getfield 69	com/j256/ormlite/stmt/StatementExecutor:tableInfo	Lcom/j256/ormlite/table/TableInfo;
    //   114: invokevirtual 178	com/j256/ormlite/table/TableInfo:getTableName	()Ljava/lang/String;
    //   117: invokevirtual 184	com/j256/ormlite/logger/Logger:debug	(Ljava/lang/String;Ljava/lang/Object;)V
    //   120: aload 10
    //   122: areturn
    //   123: astore 8
    //   125: aload 8
    //   127: athrow
    //   128: astore 5
    //   130: iload 4
    //   132: ifeq +25 -> 157
    //   135: aload_1
    //   136: iconst_1
    //   137: invokeinterface 173 2 0
    //   142: getstatic 57	com/j256/ormlite/stmt/StatementExecutor:logger	Lcom/j256/ormlite/logger/Logger;
    //   145: ldc 192
    //   147: aload_0
    //   148: getfield 69	com/j256/ormlite/stmt/StatementExecutor:tableInfo	Lcom/j256/ormlite/table/TableInfo;
    //   151: invokevirtual 178	com/j256/ormlite/table/TableInfo:getTableName	()Ljava/lang/String;
    //   154: invokevirtual 184	com/j256/ormlite/logger/Logger:debug	(Ljava/lang/String;Ljava/lang/Object;)V
    //   157: aload 5
    //   159: athrow
    //   160: astore 7
    //   162: ldc 194
    //   164: aload 7
    //   166: invokestatic 200	com/j256/ormlite/misc/SqlExceptionUtil:create	(Ljava/lang/String;Ljava/lang/Throwable;)Ljava/sql/SQLException;
    //   169: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   81	89	123	java/sql/SQLException
    //   30	38	128	finally
    //   46	54	128	finally
    //   59	81	128	finally
    //   81	89	128	finally
    //   125	128	128	finally
    //   162	170	128	finally
    //   81	89	160	java/lang/Exception
  }

  public int create(DatabaseConnection paramDatabaseConnection, T paramT, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedInsert == null)
      this.mappedInsert = MappedCreate.build(this.databaseType, this.tableInfo);
    return this.mappedInsert.insert(this.databaseType, paramDatabaseConnection, paramT, paramObjectCache);
  }

  public int delete(DatabaseConnection paramDatabaseConnection, PreparedDelete<T> paramPreparedDelete)
    throws SQLException
  {
    CompiledStatement localCompiledStatement = paramPreparedDelete.compile(paramDatabaseConnection, StatementBuilder.StatementType.DELETE);
    try
    {
      int i = localCompiledStatement.runUpdate();
      return i;
    }
    finally
    {
      localCompiledStatement.close();
    }
  }

  public int delete(DatabaseConnection paramDatabaseConnection, T paramT, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedDelete == null)
      this.mappedDelete = MappedDelete.build(this.databaseType, this.tableInfo);
    return this.mappedDelete.delete(paramDatabaseConnection, paramT, paramObjectCache);
  }

  public int deleteById(DatabaseConnection paramDatabaseConnection, ID paramID, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedDelete == null)
      this.mappedDelete = MappedDelete.build(this.databaseType, this.tableInfo);
    return this.mappedDelete.deleteById(paramDatabaseConnection, paramID, paramObjectCache);
  }

  public int deleteIds(DatabaseConnection paramDatabaseConnection, Collection<ID> paramCollection, ObjectCache paramObjectCache)
    throws SQLException
  {
    return MappedDeleteCollection.deleteIds(this.databaseType, this.tableInfo, paramDatabaseConnection, paramCollection, paramObjectCache);
  }

  public int deleteObjects(DatabaseConnection paramDatabaseConnection, Collection<T> paramCollection, ObjectCache paramObjectCache)
    throws SQLException
  {
    return MappedDeleteCollection.deleteObjects(this.databaseType, this.tableInfo, paramDatabaseConnection, paramCollection, paramObjectCache);
  }

  public int executeRaw(DatabaseConnection paramDatabaseConnection, String paramString, String[] paramArrayOfString)
    throws SQLException
  {
    logger.debug("running raw execute statement: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("execute arguments: {}", paramArrayOfString);
    CompiledStatement localCompiledStatement = paramDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.EXECUTE, noFieldTypes, -1);
    try
    {
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      int i = localCompiledStatement.runExecute();
      return i;
    }
    finally
    {
      localCompiledStatement.close();
    }
  }

  public int executeRawNoArgs(DatabaseConnection paramDatabaseConnection, String paramString)
    throws SQLException
  {
    logger.debug("running raw execute statement: {}", paramString);
    return paramDatabaseConnection.executeStatement(paramString, -1);
  }

  public RawRowMapper<T> getRawRowMapper()
  {
    if (this.rawRowMapper == null)
      this.rawRowMapper = new RawRowMapperImpl(this.tableInfo);
    return this.rawRowMapper;
  }

  public GenericRowMapper<T> getSelectStarRowMapper()
    throws SQLException
  {
    prepareQueryForAll();
    return this.preparedQueryForAll;
  }

  public boolean ifExists(DatabaseConnection paramDatabaseConnection, ID paramID)
    throws SQLException
  {
    if (this.ifExistsQuery == null)
    {
      QueryBuilder localQueryBuilder = new QueryBuilder(this.databaseType, this.tableInfo, this.dao);
      localQueryBuilder.selectRaw(new String[] { "COUNT(*)" });
      localQueryBuilder.where().eq(this.tableInfo.getIdField().getColumnName(), new SelectArg());
      this.ifExistsQuery = localQueryBuilder.prepareStatementString();
      FieldType[] arrayOfFieldType = new FieldType[1];
      arrayOfFieldType[0] = this.tableInfo.getIdField();
      this.ifExistsFieldTypes = arrayOfFieldType;
    }
    long l = paramDatabaseConnection.queryForLong(this.ifExistsQuery, new Object[] { paramID }, this.ifExistsFieldTypes);
    logger.debug("query of '{}' returned {}", this.ifExistsQuery, Long.valueOf(l));
    return l != 0L;
  }

  public String[] mapRow(DatabaseResults paramDatabaseResults)
    throws SQLException
  {
    int i = paramDatabaseResults.getColumnCount();
    String[] arrayOfString = new String[i];
    for (int j = 0; j < i; j++)
      arrayOfString[j] = paramDatabaseResults.getString(j);
    return arrayOfString;
  }

  public List<T> query(ConnectionSource paramConnectionSource, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache)
    throws SQLException
  {
    SelectIterator localSelectIterator = buildIterator(null, paramConnectionSource, paramPreparedStmt, paramObjectCache, -1);
    ArrayList localArrayList;
    try
    {
      localArrayList = new ArrayList();
      while (localSelectIterator.hasNextThrow())
        localArrayList.add(localSelectIterator.nextThrow());
    }
    finally
    {
      localSelectIterator.close();
    }
    logger.debug("query of '{}' returned {} results", paramPreparedStmt.getStatement(), Integer.valueOf(localArrayList.size()));
    localSelectIterator.close();
    return localArrayList;
  }

  public List<T> queryForAll(ConnectionSource paramConnectionSource, ObjectCache paramObjectCache)
    throws SQLException
  {
    prepareQueryForAll();
    return query(paramConnectionSource, this.preparedQueryForAll, paramObjectCache);
  }

  public long queryForCountStar(DatabaseConnection paramDatabaseConnection)
    throws SQLException
  {
    if (this.countStarQuery == null)
    {
      StringBuilder localStringBuilder = new StringBuilder(64);
      localStringBuilder.append("SELECT COUNT(*) FROM ");
      this.databaseType.appendEscapedEntityName(localStringBuilder, this.tableInfo.getTableName());
      this.countStarQuery = localStringBuilder.toString();
    }
    long l = paramDatabaseConnection.queryForLong(this.countStarQuery);
    logger.debug("query of '{}' returned {}", this.countStarQuery, Long.valueOf(l));
    return l;
  }

  public T queryForFirst(DatabaseConnection paramDatabaseConnection, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache)
    throws SQLException
  {
    CompiledStatement localCompiledStatement = paramPreparedStmt.compile(paramDatabaseConnection, StatementBuilder.StatementType.SELECT);
    DatabaseResults localDatabaseResults = null;
    try
    {
      localDatabaseResults = localCompiledStatement.runQuery(paramObjectCache);
      if (localDatabaseResults.first())
      {
        logger.debug("query-for-first of '{}' returned at least 1 result", paramPreparedStmt.getStatement());
        Object localObject2 = paramPreparedStmt.mapRow(localDatabaseResults);
        return localObject2;
      }
      logger.debug("query-for-first of '{}' returned at 0 results", paramPreparedStmt.getStatement());
      return null;
    }
    finally
    {
      if (localDatabaseResults != null)
        localDatabaseResults.close();
      localCompiledStatement.close();
    }
  }

  public T queryForId(DatabaseConnection paramDatabaseConnection, ID paramID, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedQueryForId == null)
      this.mappedQueryForId = MappedQueryForId.build(this.databaseType, this.tableInfo, null);
    return this.mappedQueryForId.execute(paramDatabaseConnection, paramID, paramObjectCache);
  }

  public long queryForLong(DatabaseConnection paramDatabaseConnection, PreparedStmt<T> paramPreparedStmt)
    throws SQLException
  {
    CompiledStatement localCompiledStatement = paramPreparedStmt.compile(paramDatabaseConnection, StatementBuilder.StatementType.SELECT_LONG);
    DatabaseResults localDatabaseResults = null;
    try
    {
      localDatabaseResults = localCompiledStatement.runQuery(null);
      if (localDatabaseResults.first())
      {
        long l = localDatabaseResults.getLong(0);
        return l;
      }
      throw new SQLException("No result found in queryForLong: " + paramPreparedStmt.getStatement());
    }
    finally
    {
      if (localDatabaseResults != null)
        localDatabaseResults.close();
      localCompiledStatement.close();
    }
  }

  public long queryForLong(DatabaseConnection paramDatabaseConnection, String paramString, String[] paramArrayOfString)
    throws SQLException
  {
    logger.debug("executing raw query for long: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("query arguments: {}", paramArrayOfString);
    CompiledStatement localCompiledStatement = null;
    DatabaseResults localDatabaseResults = null;
    try
    {
      localCompiledStatement = paramDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.SELECT, noFieldTypes, -1);
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      localDatabaseResults = localCompiledStatement.runQuery(null);
      if (localDatabaseResults.first())
      {
        long l = localDatabaseResults.getLong(0);
        return l;
      }
      throw new SQLException("No result found in queryForLong: " + paramString);
    }
    finally
    {
      if (localDatabaseResults != null)
        localDatabaseResults.close();
      if (localCompiledStatement != null)
        localCompiledStatement.close();
    }
  }

  public <UO> GenericRawResults<UO> queryRaw(ConnectionSource paramConnectionSource, String paramString, RawRowMapper<UO> paramRawRowMapper, String[] paramArrayOfString, ObjectCache paramObjectCache)
    throws SQLException
  {
    logger.debug("executing raw query for: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("query arguments: {}", paramArrayOfString);
    DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
    CompiledStatement localCompiledStatement = null;
    try
    {
      localCompiledStatement = localDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.SELECT, noFieldTypes, -1);
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      RawResultsImpl localRawResultsImpl = new RawResultsImpl(paramConnectionSource, localDatabaseConnection, paramString, [Ljava.lang.String.class, localCompiledStatement, new UserRawRowMapper(paramRawRowMapper, this), paramObjectCache);
      if (0 != 0)
        null.close();
      if (0 != 0)
        paramConnectionSource.releaseConnection(null);
      return localRawResultsImpl;
    }
    finally
    {
      if (localCompiledStatement != null)
        localCompiledStatement.close();
      if (localDatabaseConnection != null)
        paramConnectionSource.releaseConnection(localDatabaseConnection);
    }
  }

  public <UO> GenericRawResults<UO> queryRaw(ConnectionSource paramConnectionSource, String paramString, DataType[] paramArrayOfDataType, RawRowObjectMapper<UO> paramRawRowObjectMapper, String[] paramArrayOfString, ObjectCache paramObjectCache)
    throws SQLException
  {
    logger.debug("executing raw query for: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("query arguments: {}", paramArrayOfString);
    DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
    CompiledStatement localCompiledStatement = null;
    try
    {
      localCompiledStatement = localDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.SELECT, noFieldTypes, -1);
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      RawResultsImpl localRawResultsImpl = new RawResultsImpl(paramConnectionSource, localDatabaseConnection, paramString, [Ljava.lang.String.class, localCompiledStatement, new UserRawRowObjectMapper(paramRawRowObjectMapper, paramArrayOfDataType), paramObjectCache);
      if (0 != 0)
        null.close();
      if (0 != 0)
        paramConnectionSource.releaseConnection(null);
      return localRawResultsImpl;
    }
    finally
    {
      if (localCompiledStatement != null)
        localCompiledStatement.close();
      if (localDatabaseConnection != null)
        paramConnectionSource.releaseConnection(localDatabaseConnection);
    }
  }

  public GenericRawResults<Object[]> queryRaw(ConnectionSource paramConnectionSource, String paramString, DataType[] paramArrayOfDataType, String[] paramArrayOfString, ObjectCache paramObjectCache)
    throws SQLException
  {
    logger.debug("executing raw query for: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("query arguments: {}", paramArrayOfString);
    DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
    CompiledStatement localCompiledStatement = null;
    try
    {
      localCompiledStatement = localDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.SELECT, noFieldTypes, -1);
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      RawResultsImpl localRawResultsImpl = new RawResultsImpl(paramConnectionSource, localDatabaseConnection, paramString, [Ljava.lang.Object.class, localCompiledStatement, new ObjectArrayRowMapper(paramArrayOfDataType), paramObjectCache);
      if (0 != 0)
        null.close();
      if (0 != 0)
        paramConnectionSource.releaseConnection(null);
      return localRawResultsImpl;
    }
    finally
    {
      if (localCompiledStatement != null)
        localCompiledStatement.close();
      if (localDatabaseConnection != null)
        paramConnectionSource.releaseConnection(localDatabaseConnection);
    }
  }

  public GenericRawResults<String[]> queryRaw(ConnectionSource paramConnectionSource, String paramString, String[] paramArrayOfString, ObjectCache paramObjectCache)
    throws SQLException
  {
    logger.debug("executing raw query for: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("query arguments: {}", paramArrayOfString);
    DatabaseConnection localDatabaseConnection = paramConnectionSource.getReadOnlyConnection();
    CompiledStatement localCompiledStatement = null;
    try
    {
      localCompiledStatement = localDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.SELECT, noFieldTypes, -1);
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      RawResultsImpl localRawResultsImpl = new RawResultsImpl(paramConnectionSource, localDatabaseConnection, paramString, [Ljava.lang.String.class, localCompiledStatement, this, paramObjectCache);
      if (0 != 0)
        null.close();
      if (0 != 0)
        paramConnectionSource.releaseConnection(null);
      return localRawResultsImpl;
    }
    finally
    {
      if (localCompiledStatement != null)
        localCompiledStatement.close();
      if (localDatabaseConnection != null)
        paramConnectionSource.releaseConnection(localDatabaseConnection);
    }
  }

  public int refresh(DatabaseConnection paramDatabaseConnection, T paramT, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedRefresh == null)
      this.mappedRefresh = MappedRefresh.build(this.databaseType, this.tableInfo);
    return this.mappedRefresh.executeRefresh(paramDatabaseConnection, paramT, paramObjectCache);
  }

  public int update(DatabaseConnection paramDatabaseConnection, PreparedUpdate<T> paramPreparedUpdate)
    throws SQLException
  {
    CompiledStatement localCompiledStatement = paramPreparedUpdate.compile(paramDatabaseConnection, StatementBuilder.StatementType.UPDATE);
    try
    {
      int i = localCompiledStatement.runUpdate();
      return i;
    }
    finally
    {
      localCompiledStatement.close();
    }
  }

  public int update(DatabaseConnection paramDatabaseConnection, T paramT, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedUpdate == null)
      this.mappedUpdate = MappedUpdate.build(this.databaseType, this.tableInfo);
    return this.mappedUpdate.update(paramDatabaseConnection, paramT, paramObjectCache);
  }

  public int updateId(DatabaseConnection paramDatabaseConnection, T paramT, ID paramID, ObjectCache paramObjectCache)
    throws SQLException
  {
    if (this.mappedUpdateId == null)
      this.mappedUpdateId = MappedUpdateId.build(this.databaseType, this.tableInfo);
    return this.mappedUpdateId.execute(paramDatabaseConnection, paramT, paramID, paramObjectCache);
  }

  public int updateRaw(DatabaseConnection paramDatabaseConnection, String paramString, String[] paramArrayOfString)
    throws SQLException
  {
    logger.debug("running raw update statement: {}", paramString);
    if (paramArrayOfString.length > 0)
      logger.trace("update arguments: {}", paramArrayOfString);
    CompiledStatement localCompiledStatement = paramDatabaseConnection.compileStatement(paramString, StatementBuilder.StatementType.UPDATE, noFieldTypes, -1);
    try
    {
      assignStatementArguments(localCompiledStatement, paramArrayOfString);
      int i = localCompiledStatement.runUpdate();
      return i;
    }
    finally
    {
      localCompiledStatement.close();
    }
  }

  private static class ObjectArrayRowMapper
    implements GenericRowMapper<Object[]>
  {
    private final DataType[] columnTypes;

    public ObjectArrayRowMapper(DataType[] paramArrayOfDataType)
    {
      this.columnTypes = paramArrayOfDataType;
    }

    public Object[] mapRow(DatabaseResults paramDatabaseResults)
      throws SQLException
    {
      int i = paramDatabaseResults.getColumnCount();
      Object[] arrayOfObject = new Object[i];
      int j = 0;
      if (j < i)
      {
        if (j >= this.columnTypes.length);
        for (DataType localDataType = DataType.STRING; ; localDataType = this.columnTypes[j])
        {
          arrayOfObject[j] = localDataType.getDataPersister().resultToJava(null, paramDatabaseResults, j);
          j++;
          break;
        }
      }
      return arrayOfObject;
    }
  }

  private static class UserRawRowMapper<UO>
    implements GenericRowMapper<UO>
  {
    private String[] columnNames;
    private final RawRowMapper<UO> mapper;
    private final GenericRowMapper<String[]> stringRowMapper;

    public UserRawRowMapper(RawRowMapper<UO> paramRawRowMapper, GenericRowMapper<String[]> paramGenericRowMapper)
    {
      this.mapper = paramRawRowMapper;
      this.stringRowMapper = paramGenericRowMapper;
    }

    private String[] getColumnNames(DatabaseResults paramDatabaseResults)
      throws SQLException
    {
      if (this.columnNames != null)
        return this.columnNames;
      this.columnNames = paramDatabaseResults.getColumnNames();
      return this.columnNames;
    }

    public UO mapRow(DatabaseResults paramDatabaseResults)
      throws SQLException
    {
      String[] arrayOfString = (String[])this.stringRowMapper.mapRow(paramDatabaseResults);
      return this.mapper.mapRow(getColumnNames(paramDatabaseResults), arrayOfString);
    }
  }

  private static class UserRawRowObjectMapper<UO>
    implements GenericRowMapper<UO>
  {
    private String[] columnNames;
    private final DataType[] columnTypes;
    private final RawRowObjectMapper<UO> mapper;

    public UserRawRowObjectMapper(RawRowObjectMapper<UO> paramRawRowObjectMapper, DataType[] paramArrayOfDataType)
    {
      this.mapper = paramRawRowObjectMapper;
      this.columnTypes = paramArrayOfDataType;
    }

    private String[] getColumnNames(DatabaseResults paramDatabaseResults)
      throws SQLException
    {
      if (this.columnNames != null)
        return this.columnNames;
      this.columnNames = paramDatabaseResults.getColumnNames();
      return this.columnNames;
    }

    public UO mapRow(DatabaseResults paramDatabaseResults)
      throws SQLException
    {
      int i = paramDatabaseResults.getColumnCount();
      Object[] arrayOfObject = new Object[i];
      int j = 0;
      if (j < i)
      {
        if (j >= this.columnTypes.length)
          arrayOfObject[j] = null;
        while (true)
        {
          j++;
          break;
          arrayOfObject[j] = this.columnTypes[j].getDataPersister().resultToJava(null, paramDatabaseResults, j);
        }
      }
      return this.mapper.mapRow(getColumnNames(paramDatabaseResults), this.columnTypes, arrayOfObject);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.j256.ormlite.stmt.StatementExecutor
 * JD-Core Version:    0.6.2
 */